package com.jjb.www.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.PreListApi;
import com.jjb.www.http.api.TeachPlanListApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class LabelPreAdapter extends AppAdapter<PreListApi.Bean.LabelDTO> {

    public LabelPreAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvType;



        private ViewHolder() {
            super(R.layout.item_label);
            mTvType = findViewById(R.id.tv_type);
        }

        @Override
        public void onBindView(int position) {
            mTvType.setText(getItem(position).getText());
            mTvType.getShapeDrawableBuilder()
                    .setSolidColor(Color.parseColor(getItem(position).getBgColor()))
                    .intoBackground();
            mTvType.getTextColorBuilder()
                    .setTextColor(Color.parseColor(getItem(position).getColor()))
                    .intoTextColor();
        }
    }
}